
import { kdRpcCenterClient } from "kdweb-core/lib/rpc/center/centerClient"
import { ServerConfig, ServerValues } from "../../kds-base-define/src/ServerConfig"
import { Config } from "./config"
import { RpcUserLogin, RpcUserInfo, RpcUserRoomStatus, RpcUserNodeStatus, RpcUserFlag, RpcUserFlagRedis, RpcUserNodeStatusRedis,RpcNewGoldInfo, RpcBonusTea } from "./rpc/user"
import { RpcRoom, RpcRoomRealtime, RpcRoomTea } from "./rpc/room"
import { RpcTea, RpcTeaGet, RpcTeaUpdate, RpcTeaService } from "./rpc/tea_redis"
import { RpcMail, RpcNewMail } from "./rpc/mail"
import { RpcRecord } from "./rpc/record"
import { RpcChangedKV, RpcKV, RpcMongoKV } from "./rpc/kv"
import { RpcGroup, RpcMatch, RpcMatchRealtime } from "./rpc/match"
import { RpcSrs } from "./rpc/srs"
import { RpcUserGameRecord } from "./rpc/user_gameRecord"
import { RpcDbpCacheMethods, DbpCaches } from "./cache/RpcCache"
import { RpcTeaRecord } from "./rpc/tea_record"
import { RpcTeaUser } from "./rpc/tea_redis"
import { RpcItem, RpcItemConfig } from "./rpc/item"
import { RpcGameNameConfig } from "./rpc/gameNames"
import { RpcTeaUserAccount } from "./rpc/tea_account"
import { RpcRobotRecord } from "./rpc/robot"
import { RpcRankTea } from "./rpc/rank"
import { RpcAdminTea } from "./rpc/admin"
export namespace Rpc {
	export let center:kdRpcCenterClient.entity

	
	export function init() {
		if(ServerValues.localIp) {
			kdRpcCenterClient.setupLocalHostReplacement(ServerValues.localIp)
		}
		center = new kdRpcCenterClient.entity({
			centerHost:ServerValues.rpcCenterHost,
			port:Config.myConfig.wsPort,
			token:ServerValues.rpcToken,
			info: {
				name: Config.myName,
				tag: Config.myName,
				host: Config.myConfig.wsHost,
				auth: "DDD",
				version: "1.0",
				timestamp: 0,
				data: null
			}
		})
		center.logUrlPath = ServerValues.rpcLoggerHost
		center.addGroup("kds.dbp.user.login",RpcUserLogin)
		center.addGroup("kds.dbp.user.userInfo",RpcUserInfo)
        // center.addGroup("kds.dbp.user.real", RpcUserRealName); //新增实名
		// /** 2023/3/6 新增排行榜逻辑 */
		center.addGroup("kds.dbp.rank", RpcRankTea)

		// /** 2023/4/19 新增后台管理用户操作log */
		center.addGroup("kds.dbp.Cdg", RpcBonusTea)
	
		// /** 2023/4/19 新增后台管理 */
		center.addGroup("kds.dbp.admin", RpcAdminTea)
		
		center.addGroup("kds.dbp.new.gold", RpcNewGoldInfo)

		center.addGroup("kds.dbp.user.room",RpcUserRoomStatus)
		center.addGroup("kds.dbp.user.flag",RpcUserFlagRedis)
		center.addGroup("kds.dbp.user.node",RpcUserNodeStatusRedis)
		center.addGroup("kds.dbp.user.mail",RpcMail)
		center.addGroup("kds.dbp.user.mail.new",RpcNewMail)
		center.addGroup("kds.dbp.user.gamerecord",RpcUserGameRecord)

		center.addGroup("kds.dbp.room",RpcRoom)
		center.addGroup("kds.dbp.room.real",RpcRoomRealtime)
		center.addGroup("kds.dbp.room.tea",RpcRoomTea)
		
		center.addGroup("kds.dbp.tea",RpcTea)
		center.addGroup("kds.dbp.tea.get",RpcTeaGet)
		center.addGroup("kds.dbp.tea.update",RpcTeaUpdate)
		center.addGroup("kds.dbp.tea.record",RpcTeaRecord)
		center.addGroup("kds.dbp.tea.user",RpcTeaUser)
		center.addGroup("kds.dbp.tea.service",RpcTeaService)
		center.addGroup("kds.dbp.tea.useraccount",RpcTeaUserAccount)

		center.addGroup("kds.dbp.record",RpcRecord)
		
		center.addGroup("kds.dbp.srs",RpcSrs)

		center.addGroup("kds.dbp.group",RpcGroup)
		center.addGroup("kds.dbp.match",RpcMatch)
		center.addGroup("kds.dbp.match.realtime",RpcMatchRealtime)

		center.addGroup("kds.dbp.kv",RpcKV)
		center.addGroup("kds.dbp.kv.c",RpcChangedKV)
		center.addGroup("kds.dbp.kv.m",RpcMongoKV)

		center.addGroup("kds.dbp.config.gid",RpcGameNameConfig)
		
		center.addGroup("kds.dbp.cache",RpcDbpCacheMethods)
		DbpCaches.mgr.reg()
		// kds.dbp.cache.loginData.[get set]

		center.addGroup("kds.dbp.item",RpcItem)
		center.addGroup("kds.dbp.item.config",RpcItemConfig)

		center.addGroup("kds.dbp.robot.record",RpcRobotRecord)
	}
}